package com.huazai.lock;

import java.util.concurrent.CountDownLatch;

/**
 * 减少计数
 *
 * @author huazai
 * @date 2024/2/4
 */
public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(5);
        for (int i = 0; i < 5; i++) {
            int finalI = i;
            new Thread(() -> {
                System.out.println("i = " + finalI);
                countDownLatch.countDown();
            }).start();
        }
        countDownLatch.await();
        System.out.println("countDownLatch 完成");
    }
}
